package com.etc.web;



import com.etc.dao.StudentMapper;
import com.etc.dao.User_attendanceMapper;
import com.etc.dao.User_classMapper;
import com.etc.model.Student;
import com.etc.model.User_attendance;
import com.etc.model.User_class;
import com.etc.service.IFileToExcelService;
import com.etc.service.IFileUploadService;
import com.etc.service.impl.IFileHanderUserAttendanceImpl;
import com.etc.service.impl.StudentServiceImpl;
import com.etc.vo.StudentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

/**
 * 主页页面控制器
 */
@Controller

public class FileUpControler {
    @Autowired
    private IFileToExcelService iFileToExcelService;
    @Autowired
    private IFileUploadService iFileUploadService;
    @Autowired
    private IFileHanderUserAttendanceImpl iFileHanderUserAttendance;


    /*    private static final Logger log = (Logger) LoggerFactory.getLogger(FileUpControler.class);*/

    @RequestMapping(value = "/upload")
    @ResponseBody
    public List<StudentVo> upload(@RequestParam("file") MultipartFile file, String classnodeUpload, String classnameUpload, String usernameUpload) {
        List<User_class> studentList = new ArrayList<>();
        HttpSession httpSession;
        List<StudentVo> studentVos = new ArrayList<>();
        String path=iFileUploadService.upload(file);
        studentList = iFileToExcelService.importExcel(path,classnodeUpload,classnameUpload);
        studentVos=iFileHanderUserAttendance.IFileHanderUserAttendance(studentList,classnodeUpload);
        return studentVos;





    }
}
